﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UtilZ.Dotnet.Ex.Base;

namespace UtilZ.Dotnet.Ex.Communication.Net.MQBase
{
    /// <summary>
    /// MQ二进制消息
    /// </summary>
    public class MQBytesMessage : MQMessageAbs
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public MQBytesMessage()
            : base(MQMessageType.Bytes)
        {

        }

        private byte[] _content = null;
        /// <summary>
        /// 内容
        /// </summary>
        public byte[] Content
        {
            get { return _content; }
            set { _content = value; }
        }

        /// <summary>
        /// 消息体
        /// </summary>
        public override object Body
        {
            get { return _content; }
            set { _content = (byte[])value; }
        }

        /// <summary>
        /// 重写ToString
        /// </summary>
        /// <returns>String</returns>
        public override string ToString()
        {
            if (this._content == null)
            {
                return string.Empty;
            }

            return ConvertEx.BytesToHexadecimaString(this._content);
        }
    }
}
